library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble  3.1.0     ✓ purrr   0.3.4
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(arsenal)
library(data.table)
## 
## Attaching package: 'data.table'
## The following object is masked from 'package:purrr':
## 
##     transpose
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
library(expss)
## 
## Use 'expss_output_rnotebook()' to display tables inside R Notebooks.
##  To return to the console output, use 'expss_output_default()'.
## 
## Attaching package: 'expss'
## The following objects are masked from 'package:data.table':
## 
##     copy, like
## The following objects are masked from 'package:stringr':
## 
##     fixed, regex
## The following objects are masked from 'package:purrr':
## 
##     keep, modify, modify_if, transpose, when
## The following objects are masked from 'package:tidyr':
## 
##     contains, nest
## The following objects are masked from 'package:dplyr':
## 
##     between, compute, contains, first, last, na_if, recode, vars
## The following object is masked from 'package:ggplot2':
## 
##     vars
library(ggsci)

#ideas, stratify by what do you consider a good nights sleep
#additive index according to behaviors 
#regression models for the outcome.

#Positive quality of sleep - 
#Consistent wake up 
#Greater than 7 hrs to 9 hrs --> stratify #for sure USE THIS AND ONE OR THE OTHER
  #Agreement questions Q44
  #Current bedtime routines
  #Current lifestyle habits
  #Employment and children
analysisdata <- readRDS("foranalysis.rds")
analysisdata <- analysisdata %>% mutate(
  compositeoutcomegoodsleep = case_when(
    Q10_workdayhoursofsleep >= 7.0 & Q10_workdayhoursofsleep <= 9.0 ~ 1,
    Q10_workdayhoursofsleep < 7.0 | Q10_workdayhoursofsleep > 9.0 ~ 0,
    Q44_6_ifeelpositiveaboutthequalityofmysleep == "Somewhat agree" & Q13_consistentwakeup == "Yes" ~ 1,
    Q44_6_ifeelpositiveaboutthequalityofmysleep == "Strongly agree" & Q13_consistentwakeup == "Yes"~ 1,
    Q44_6_ifeelpositiveaboutthequalityofmysleep == "Strongly disagree" & (Q13_consistentwakeup == "No" | Q13_consistentwakeup == "Sometimes") ~ 0,
    Q44_6_ifeelpositiveaboutthequalityofmysleep == "Somewhat disagree" & (Q13_consistentwakeup == "No" | Q13_consistentwakeup == "Sometimes") ~ 0,
    Q44_6_ifeelpositiveaboutthequalityofmysleep == "Neither agree nor disagree" & (Q13_consistentwakeup == "No" | Q13_consistentwakeup == "Sometimes") ~ 0
  )
) %>% mutate(compositeoutcomegoodsleep = factor(compositeoutcomegoodsleep, label = c("Poor sleep", "Good sleep"))) %>%
  filter(!is.na(compositeoutcomegoodsleep))
tab1 <- tableby(compositeoutcomegoodsleep~ Q3_role + 
                  Q4_gender +
                  Q5_age +
                  Q6_numberinhousehold +
                  Q37_employed +
                  Q8_diagnosis +
                  Q10_workdayhoursofsleep +
                  Q11_weekendhoursofsleep +
                  Q9_howoftensleepy,
                data=analysisdata, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Poor sleep (N=70) Good sleep (N=133) Total (N=203) p value
What is your role at Bloomberg 0.7051
   Faculty/Staff Member 3 (4.3%) 3 (2.3%) 6 (3.0%)
   Full-time student 47 (67.1%) 93 (69.9%) 140 (69.0%)
   Part-time student 20 (28.6%) 37 (27.8%) 57 (28.1%)
What gender do you identify as? 0.1581
   Female 53 (75.7%) 110 (82.7%) 163 (80.3%)
   Male 13 (18.6%) 22 (16.5%) 35 (17.2%)
   Non-binary / third gender 3 (4.3%) 1 (0.8%) 4 (2.0%)
   Prefer not to say 1 (1.4%) 0 (0.0%) 1 (0.5%)
How old are you? 0.7352
   Median (Q1, Q3) 28.00 (25.00, 33.25) 28.00 (25.00, 32.00) 28.00 (25.00, 32.00)
How many people live in your household, including yourself? 0.4782
   Median (Q1, Q3) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00) 2.00 (2.00, 3.00)
Are you currently employed outside of your education program? 0.7071
   N-Miss 0 1 1
   No 32 (45.7%) 64 (48.5%) 96 (47.5%)
   Yes 38 (54.3%) 68 (51.5%) 106 (52.5%)
Have you ever been diagnosed with any of the following sleep disorders? 0.6021
   Insomnia 4 (5.7%) 8 (6.0%) 12 (5.9%)
   No 62 (88.6%) 122 (91.7%) 184 (90.6%)
   Other 2 (2.9%) 1 (0.8%) 3 (1.5%)
   Sleep Apnea 2 (2.9%) 2 (1.5%) 4 (2.0%)
During the past 5 workdays, how many hours of sleep did you get per night on average? < 0.0012
   Median (Q1, Q3) 6.00 (5.00, 6.00) 7.00 (7.00, 8.00) 7.00 (6.00, 7.50)
During the past weekend, how many hours of sleep did you get per night on average? < 0.0012
   Median (Q1, Q3) 7.00 (6.00, 8.50) 8.00 (7.50, 9.00) 8.00 (7.00, 9.00)
How often do you feel sleepy during the day?
   N-Miss 27 38 65
   Never 0 (0.0%) 3 (3.2%) 3 (2.2%)
   Rarely 6 (14.0%) 20 (21.1%) 26 (18.8%)
   Sometimes 29 (67.4%) 69 (72.6%) 98 (71.0%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 8 (18.6%) 3 (3.2%) 11 (8.0%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test
#If student
student <- analysisdata %>% filter(Q3_role != "Faculty/Staff Member")

tab1 <- tableby(compositeoutcomegoodsleep~ Q2_program,
                data=student, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Poor sleep (N=67) Good sleep (N=130) Total (N=197) p value
What is your current program at Bloomberg? 0.4241
   Doctoral Student 14 (20.9%) 40 (30.8%) 54 (27.4%)
   Masters Student 51 (76.1%) 86 (66.2%) 137 (69.5%)
   Other 0 (0.0%) 1 (0.8%) 1 (0.5%)
   Post doctoral student 2 (3.0%) 3 (2.3%) 5 (2.5%)
  1. Pearson’s Chi-squared test
#If employed 
employed <- analysisdata %>% filter(Q37_employed == "Yes")

tab1 <- tableby(compositeoutcomegoodsleep ~ Q38_wfh,
                data=employed, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Poor sleep (N=38) Good sleep (N=68) Total (N=106) p value
Do you work from home? 0.5761
   No 12 (31.6%) 18 (26.5%) 30 (28.3%)
   Yes 26 (68.4%) 50 (73.5%) 76 (71.7%)
  1. Pearson’s Chi-squared test
#If wfh
notworkfromhome <- analysisdata %>% filter(Q37_employed == "Yes" & Q38_wfh == "No")

tab1 <- tableby(compositeoutcomegoodsleep ~ Q39_dayornight,
                data=notworkfromhome, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 1. Baseline information', pfootnote=TRUE, digits = 2)
Table 1. Baseline information
Poor sleep (N=12) Good sleep (N=18) Total (N=30) p value
Do you work day or night shifts? 0.3481
   N-Miss 0 1 1
   Day shift 10 (83.3%) 16 (94.1%) 26 (89.7%)
   Night shift 2 (16.7%) 1 (5.9%) 3 (10.3%)
  1. Pearson’s Chi-squared test
tab1 <- tableby(compositeoutcomegoodsleep~  
                  Q15_consistentbedtimeonweekdays +
                  Q49_sleepqualitychangecovid +
                  bedtimeroutine +
                  Q19_howmanyhourssdidyouuseascreen +
                  as.numeric(Q19_howmanyhourssdidyouuseascreen) +
                  Q12_1_howmanynightsusescreen +
                  Q17_stressedaboutschool +
                  cantsleepfeeling +
                  Q18_howoftenpracticemindfullness +
                  behaviors +
                  Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep +
                  Q44_2_gettingagoodnightssleepisimportantome +
                  Q44_3_mostofmyfriendshaveahealthysleeproutine +
                  Q44_4_lackofsleepaffectsmyacademicperformance +
                  Q44_5_havingaregularsleeproutineimprovesmentalclariy +
                  Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep +
                  Q44_8_ithinkingworkingoutregularlyleadstobettersleep +
                  Q44_9_ithinkmeditatingbeforesleephelpsquality +
                  Q59_1_icanmaintainhealthysleephabits +
                  Q59_2_icancutoutscreenuseonehourbeforesleep +
                  Q59_3_icanworkoutregularly +
                  Q59_4_icanmediatebeforebed +
                  Q37_whatdoyouconsideragoodnightssleep +
                  Q50_1_energyfordailyacitivites +
                  Q50_2_attractivness +
                  Q50_3_productivity +
                  Q50_4_accomplishmentofotherdailygoals +
                  Q50_5_mentalandemotionalwellbeing +
                  Q50_6_fosteringmaintaingrelationships +
                  Q50_7_caringforchildren +
                  Q53_1_getoutsidefor10mininthemorning +
                  Q53_2_exerciseduringtheday +
                  Q53_3_doingabreathingexercisebeforesleep +
                  Q53_4_notusescreens +
                  Q53_5_listeningtoacalmingaudiobookorpodcast +
                  information,
                data=analysisdata, test=TRUE, total=TRUE, 
                numeric.stats=c("medianq1q3"), numeric.test="kwt", cat.test="chisq")
summary(tab1, title='Table 2. Sleep questions', pfootnote=TRUE, digits = 2)
Table 2. Sleep questions
Poor sleep (N=70) Good sleep (N=133) Total (N=203) p value
Do you have a consistent time you wake up on weekdays? < 0.0011
   No 45 (64.3%) 41 (30.8%) 86 (42.4%)
   Sometimes 13 (18.6%) 34 (25.6%) 47 (23.2%)
   Yes 12 (17.1%) 58 (43.6%) 70 (34.5%)
Has your sleep quality changed due to the COVID-19 pandemic? 0.0821
   N-Miss 1 1 2
   No 23 (33.3%) 50 (37.9%) 73 (36.3%)
   Yes, I feel my sleep quality has improved 5 (7.2%) 22 (16.7%) 27 (13.4%)
   Yes, I feel my sleep quality has worsened 41 (59.4%) 60 (45.5%) 101 (50.2%)
My bedtime routine includes: 0.2901
   N-Miss 0 1 1
   Brushing teeth 20 (28.6%) 46 (34.8%) 66 (32.7%)
   Phone usage 2 (2.9%) 7 (5.3%) 9 (4.5%)
   Reading 4 (5.7%) 1 (0.8%) 5 (2.5%)
   Showering 1 (1.4%) 1 (0.8%) 2 (1.0%)
   Washing my face 42 (60.0%) 76 (57.6%) 118 (58.4%)
   Watching TV 1 (1.4%) 1 (0.8%) 2 (1.0%)
How many hours per day do you typically use a screen? (i.e. cell phone, tablet, computer, television)
   N-Miss 2 1 3
   0 0 (0.0%) 0 (0.0%) 0 (0.0%)
   1 0 (0.0%) 0 (0.0%) 0 (0.0%)
   2 0 (0.0%) 0 (0.0%) 0 (0.0%)
   3 1 (1.5%) 2 (1.5%) 3 (1.5%)
   4 1 (1.5%) 4 (3.0%) 5 (2.5%)
   5 0 (0.0%) 5 (3.8%) 5 (2.5%)
   6 5 (7.4%) 4 (3.0%) 9 (4.5%)
   7 2 (2.9%) 3 (2.3%) 5 (2.5%)
   8 8 (11.8%) 20 (15.2%) 28 (14.0%)
   9 3 (4.4%) 7 (5.3%) 10 (5.0%)
   10 17 (25.0%) 39 (29.5%) 56 (28.0%)
   11 2 (2.9%) 0 (0.0%) 2 (1.0%)
   12 16 (23.5%) 35 (26.5%) 51 (25.5%)
   13 1 (1.5%) 3 (2.3%) 4 (2.0%)
   14 6 (8.8%) 7 (5.3%) 13 (6.5%)
   15 4 (5.9%) 1 (0.8%) 5 (2.5%)
   16 1 (1.5%) 2 (1.5%) 3 (1.5%)
   17 1 (1.5%) 0 (0.0%) 1 (0.5%)
How many hours per day do you typically use a screen? (i.e. cell phone, tablet, computer, television) 0.1822
   Median (Q1, Q3) 11.00 (9.75, 13.00) 11.00 (9.00, 13.00) 11.00 (9.00, 13.00)
In the past week, how many nights did you use screens (i.e. cell phone, tablet, computer, television) within 1 hour before bed? 0.0492
   Median (Q1, Q3) 7.00 (7.00, 7.00) 7.00 (6.00, 7.00) 7.00 (7.00, 7.00)
How stressed do you currently feel about school? 0.0162
   Median (Q1, Q3) 7.00 (6.00, 9.00) 7.00 (5.00, 8.00) 7.00 (5.00, 8.00)
When you can’t sleep do you feel 0.5861
   Angry 3 (4.3%) 10 (7.5%) 13 (6.4%)
   Frustrated 33 (47.1%) 70 (52.6%) 103 (50.7%)
   Guilty 14 (20.0%) 20 (15.0%) 34 (16.7%)
   None of the above 4 (5.7%) 9 (6.8%) 13 (6.4%)
   Other 4 (5.7%) 6 (4.5%) 10 (4.9%)
   Sad 4 (5.7%) 2 (1.5%) 6 (3.0%)
   Stressed 8 (11.4%) 16 (12.0%) 24 (11.8%)
How often do you practice mindfulness techniques? (i.e. breathing exercises, meditation, etc.,)
   N-Miss 6 12 18
   Never 10 (15.6%) 23 (19.0%) 33 (17.8%)
   Rarely 31 (48.4%) 44 (36.4%) 75 (40.5%)
   Sometimes 22 (34.4%) 50 (41.3%) 72 (38.9%)
   Very often 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Always 1 (1.6%) 4 (3.3%) 5 (2.7%)
Which of the following behaviors do you participate in? 0.0371
   N-Miss 1 1 2
   Alcohol Consumption 24 (34.8%) 73 (55.3%) 97 (48.3%)
   Cigarette smoking 3 (4.3%) 1 (0.8%) 4 (2.0%)
   Daytime napping 0 (0.0%) 1 (0.8%) 1 (0.5%)
   Drinking Caffeinated beverages 2 (2.9%) 2 (1.5%) 4 (2.0%)
   Exercise 27 (39.1%) 43 (32.6%) 70 (34.8%)
   Social Media Use 13 (18.8%) 12 (9.1%) 25 (12.4%)
The things I do in the last hour before bed affect the quality of my sleep. 0.8371
   Strongly disagree 3 (4.3%) 4 (3.0%) 7 (3.4%)
   Somewhat disagree 6 (8.6%) 8 (6.0%) 14 (6.9%)
   Neither agree nor disagree 8 (11.4%) 11 (8.3%) 19 (9.4%)
   Somewhat agree 31 (44.3%) 63 (47.4%) 94 (46.3%)
   Strongly agree 22 (31.4%) 47 (35.3%) 69 (34.0%)
Getting a good night’s sleep is important to me. 0.0301
   Strongly disagree 0 (0.0%) 1 (0.8%) 1 (0.5%)
   Somewhat disagree 0 (0.0%) 1 (0.8%) 1 (0.5%)
   Neither agree nor disagree 3 (4.3%) 1 (0.8%) 4 (2.0%)
   Somewhat agree 16 (22.9%) 13 (9.8%) 29 (14.3%)
   Strongly agree 51 (72.9%) 117 (88.0%) 168 (82.8%)
Most of my friends have a healthy sleep routine. 0.0451
   N-Miss 1 0 1
   Strongly disagree 6 (8.7%) 3 (2.3%) 9 (4.5%)
   Somewhat disagree 14 (20.3%) 27 (20.3%) 41 (20.3%)
   Neither agree nor disagree 25 (36.2%) 71 (53.4%) 96 (47.5%)
   Somewhat agree 18 (26.1%) 27 (20.3%) 45 (22.3%)
   Strongly agree 6 (8.7%) 5 (3.8%) 11 (5.4%)
Lack of sleep affects my academic performance. 0.7391
   N-Miss 1 0 1
   Strongly disagree 1 (1.4%) 2 (1.5%) 3 (1.5%)
   Somewhat disagree 4 (5.8%) 7 (5.3%) 11 (5.4%)
   Neither agree nor disagree 7 (10.1%) 7 (5.3%) 14 (6.9%)
   Somewhat agree 25 (36.2%) 56 (42.1%) 81 (40.1%)
   Strongly agree 32 (46.4%) 61 (45.9%) 93 (46.0%)
Having a regular sleep routine improves mental clarity/sharpness.
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 0 (0.0%) 1 (0.8%) 1 (0.5%)
   Neither agree nor disagree 4 (5.7%) 6 (4.5%) 10 (4.9%)
   Somewhat agree 14 (20.0%) 37 (27.8%) 51 (25.1%)
   Strongly agree 52 (74.3%) 89 (66.9%) 141 (69.5%)
I think cutting out screen use 1 hour before bed leads to better sleep. 0.1931
   Strongly disagree 5 (7.1%) 3 (2.3%) 8 (3.9%)
   Somewhat disagree 4 (5.7%) 2 (1.5%) 6 (3.0%)
   Neither agree nor disagree 12 (17.1%) 27 (20.3%) 39 (19.2%)
   Somewhat agree 29 (41.4%) 57 (42.9%) 86 (42.4%)
   Strongly agree 20 (28.6%) 44 (33.1%) 64 (31.5%)
I think working out regularly leads to better sleep.
   Strongly disagree 0 (0.0%) 0 (0.0%) 0 (0.0%)
   Somewhat disagree 2 (2.9%) 1 (0.8%) 3 (1.5%)
   Neither agree nor disagree 4 (5.7%) 13 (9.8%) 17 (8.4%)
   Somewhat agree 23 (32.9%) 36 (27.1%) 59 (29.1%)
   Strongly agree 41 (58.6%) 83 (62.4%) 124 (61.1%)
I think meditating before bed helps sleep quality. 0.1141
   N-Miss 0 1 1
   Strongly disagree 5 (7.1%) 1 (0.8%) 6 (3.0%)
   Somewhat disagree 5 (7.1%) 6 (4.5%) 11 (5.4%)
   Neither agree nor disagree 23 (32.9%) 45 (34.1%) 68 (33.7%)
   Somewhat agree 20 (28.6%) 46 (34.8%) 66 (32.7%)
   Strongly agree 17 (24.3%) 34 (25.8%) 51 (25.2%)
I can maintain healthy sleep habits. < 0.0011
   N-Miss 0 1 1
   Not at all confident 8 (11.4%) 6 (4.5%) 14 (6.9%)
   Slightly confident 19 (27.1%) 9 (6.8%) 28 (13.9%)
   Somewhat confident 24 (34.3%) 41 (31.1%) 65 (32.2%)
   Pretty confident 18 (25.7%) 54 (40.9%) 72 (35.6%)
   Extremely confident 1 (1.4%) 22 (16.7%) 23 (11.4%)
I can cut out screen use 1 hour before bed. 0.3741
   N-Miss 0 1 1
   Not at all confident 18 (25.7%) 27 (20.5%) 45 (22.3%)
   Slightly confident 25 (35.7%) 38 (28.8%) 63 (31.2%)
   Somewhat confident 15 (21.4%) 36 (27.3%) 51 (25.2%)
   Pretty confident 6 (8.6%) 22 (16.7%) 28 (13.9%)
   Extremely confident 6 (8.6%) 9 (6.8%) 15 (7.4%)
I can work out regularly. 0.0911
   N-Miss 1 1 2
   Not at all confident 9 (13.0%) 6 (4.5%) 15 (7.5%)
   Slightly confident 16 (23.2%) 21 (15.9%) 37 (18.4%)
   Somewhat confident 12 (17.4%) 27 (20.5%) 39 (19.4%)
   Pretty confident 17 (24.6%) 34 (25.8%) 51 (25.4%)
   Extremely confident 15 (21.7%) 44 (33.3%) 59 (29.4%)
I can meditate before bed. 0.5391
   N-Miss 0 1 1
   Not at all confident 15 (21.4%) 29 (22.0%) 44 (21.8%)
   Slightly confident 18 (25.7%) 34 (25.8%) 52 (25.7%)
   Somewhat confident 23 (32.9%) 32 (24.2%) 55 (27.2%)
   Pretty confident 8 (11.4%) 26 (19.7%) 34 (16.8%)
   Extremely confident 6 (8.6%) 11 (8.3%) 17 (8.4%)
What do you consider a good night’s sleep? 0.0061
   10+ hours 1 (1.4%) 0 (0.0%) 1 (0.5%)
   7 hours 16 (22.9%) 13 (9.8%) 29 (14.3%)
   8 hours 47 (67.1%) 93 (69.9%) 140 (69.0%)
   9 hours 5 (7.1%) 27 (20.3%) 32 (15.8%)
   Less than or equal to 6 hours 1 (1.4%) 0 (0.0%) 1 (0.5%)
Energy for daily activities 0.4962
   Median (Q1, Q3) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00)
Attractiveness (to self & others) 0.0072
   Median (Q1, Q3) 4.00 (3.00, 4.00) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00)
Productivity at work/school 0.2562
   Median (Q1, Q3) 5.00 (5.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00)
Accomplishment of other daily goals (e.g. exercise, cooking, paying bills, etc) 0.2882
   Median (Q1, Q3) 5.00 (4.00, 5.00) 4.00 (4.00, 5.00) 5.00 (4.00, 5.00)
Mental and emotional wellbeing 0.5222
   Median (Q1, Q3) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00) 5.00 (4.00, 5.00)
Fostering/maintaining relationships 0.4182
   Median (Q1, Q3) 4.00 (4.00, 5.00) 4.00 (3.00, 5.00) 4.00 (3.00, 5.00)
Caring for children 0.5732
   Median (Q1, Q3) 1.00 (1.00, 4.00) 1.00 (1.00, 3.00) 1.00 (1.00, 3.50)
Get outside for 10 minutes in the morning. 0.9832
   Median (Q1, Q3) 4.00 (2.00, 5.00) 4.00 (2.00, 5.00) 4.00 (2.00, 5.00)
Exercise during the day. 0.0252
   Median (Q1, Q3) 4.00 (3.00, 5.00) 4.00 (3.00, 5.00) 4.00 (3.00, 5.00)
Do a breathing exercise before you sleep. 0.2542
   Median (Q1, Q3) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00)
Not use screens (i.e. cell phone, tablet, computer, television) for 1 hour before bed 0.0142
   Median (Q1, Q3) 2.00 (1.00, 3.00) 3.00 (2.00, 3.00) 2.00 (2.00, 3.00)
Listen to a calming audiobook or podcast before bed 0.9792
   Median (Q1, Q3) 3.00 (1.00, 4.00) 3.00 (2.00, 4.00) 3.00 (2.00, 4.00)
Where have you seen or received information about sleep quality or sleep hygiene? 0.0241
   N-Miss 5 10 15
   Friends 0 (0.0%) 8 (6.5%) 8 (4.3%)
   Health care professional 30 (46.2%) 40 (32.5%) 70 (37.2%)
   News sources 4 (6.2%) 9 (7.3%) 13 (6.9%)
   Other online source 7 (10.8%) 17 (13.8%) 24 (12.8%)
   Social media 15 (23.1%) 43 (35.0%) 58 (30.9%)
   University wellbeing resources 9 (13.8%) 6 (4.9%) 15 (8.0%)
  1. Pearson’s Chi-squared test
  2. Kruskal-Wallis rank sum test

Fig 1

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q3_role, fill=compositeoutcomegoodsleep)) +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Role") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 2

g<- ggplot(student) + 
  geom_bar(aes(x=Q2_program, fill=compositeoutcomegoodsleep)) +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "What is your current program at Bloomberg?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 3

g<- ggplot(student) + 
  geom_bar(aes(x=Q4_gender, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "What gender do you identify as?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 4

g<- ggplot(student) + 
  geom_bar(aes(x=Q37_employed, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Are you currently employed outside of your education program?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 5

g<- ggplot(employed) + 
  geom_bar(aes(x=Q38_wfh, fill=compositeoutcomegoodsleep)) +
  coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you work from home?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 6

g<- ggplot(notworkfromhome) + 
  geom_bar(aes(x=Q39_dayornight, fill=compositeoutcomegoodsleep)) +
  coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you work day or night shifts?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 7

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q7_children, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=15)) +
  labs(title = "Are there children living in your household?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 8

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q8_diagnosis, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=20), axis.text.x = element_text(size=32)) +
  labs(title = "Have you ever been diagnosed with any of the following sleep disorders?") +
  xlab("") + 
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 9

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q9_howoftensleepy, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "How often do you feel sleepy during the day?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 10

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q13_consistentwakeup, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=32)) +
  labs(title = "Do you have a consistent time you wake up on weekdays?") +
  xlab("") + 
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 11

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q15_consistentbedtimeonweekdays, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Do you have a consistent bedtime on weekdays?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 12

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q49_sleepqualitychangecovid, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Has your sleep quality changed due to the COVID-19 pandemic?") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 13

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=bedtimeroutine, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "My bedtime routine includes") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 14

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q17_stressedaboutschool, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "How stressed do you currently feel about school?") +
  xlab("") + 
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 2 rows containing non-finite values (stat_count).

Fig 15

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=cantsleepfeeling, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "When you can't sleep do you feel") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 16

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q18_howoftenpracticemindfullness, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "How often do you practice mindfulness techniques? (i.e. breathing exercises, meditation, etc.,") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 17

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=behaviors, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Which of the following behaviors do you participate in? Check all that apply. ") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 18

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_1_thingsidointhelasthourbeforesleepaffectthequalityofmysleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "The things I do in the last hour before bed affect the quality of my sleep.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_2_gettingagoodnightssleepisimportantome, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Getting a good night's sleep is important to me.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_3_mostofmyfriendshaveahealthysleeproutine, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Most of my friends have a healthy sleep routine.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_4_lackofsleepaffectsmyacademicperformance, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Lack of sleep affects my academic performance.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_5_havingaregularsleeproutineimprovesmentalclariy, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Having a regular sleep routine improves mental clarity/sharpness.") +
  xlab("") +
  labs(fill='') 
g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_6_ifeelpositiveaboutthequalityofmysleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I feel positive about the quality of my sleep.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_7_ithinkcuttingoutscreenuseonehourbeforesleepleadstobettersleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think cutting out screen use 1 hour before bed leads to better sleep.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_8_ithinkingworkingoutregularlyleadstobettersleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think working out regularly leads to better sleep.") +
  xlab("") +
  labs(fill='') 
g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q44_9_ithinkmeditatingbeforesleephelpsquality, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I think meditating before bed helps sleep quality.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 19

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_1_icanmaintainhealthysleephabits, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can maintain healthy sleep habits.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_2_icancutoutscreenuseonehourbeforesleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can cut out screen use 1 hour before bed.") +
  xlab("") +
  labs(fill='') 
g+ scale_fill_lancet() 

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_3_icanworkoutregularly, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can work out regularly.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_4_icanmediatebeforebed, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can meditate before bed.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 20

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_1_energyfordailyacitivites, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Energy for daily activities") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_2_attractivness, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Attractiveness (to self & others)") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_3_productivity, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Productivity at work/school") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_4_accomplishmentofotherdailygoals, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Accomplishment of other daily goals (e.g. exercise, cooking, paying bills, etc)") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 1 rows containing non-finite values (stat_count).

g<- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_5_mentalandemotionalwellbeing, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Mental and emotional wellbeing") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 2 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_6_fosteringmaintaingrelationships, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Fostering/maintaining relationships") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 2 rows containing non-finite values (stat_count).

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q50_7_caringforchildren, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "Caring for children") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 
## Warning: Removed 8 rows containing non-finite values (stat_count).

Fig 21

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_1_icanmaintainhealthysleephabits, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can maintain healthy sleep habits.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

g <- ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_2_icancutoutscreenuseonehourbeforesleep, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can cut out screen use 1 hour before bed.") +
  xlab("") +
  labs(fill='')  

g+ scale_fill_lancet() 

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_3_icanworkoutregularly, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can work out regularly.") +
  xlab("") +
  labs(fill='') 

g + scale_fill_lancet() 

g <-ggplot(analysisdata) + 
  geom_bar(aes(x=Q59_4_icanmediatebeforebed, fill=compositeoutcomegoodsleep)) +
  #coord_flip() +
  theme_test() +
  theme(text = element_text(size=32), axis.text.x = element_text(size=18)) +
  labs(title = "I can meditate before bed.") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet() 

Fig 22

g<-ggplot(analysisdata) + 
  geom_bar(aes(x=information, fill=compositeoutcomegoodsleep)) +
  theme_test() +
  theme(text = element_text(size=20), axis.text.x = element_text(size=16)) +
  labs(title = "Where have you seen or received information about sleep quality or sleep hygiene? Check all that apply. ") +
  xlab("") +
  labs(fill='') 

g+ scale_fill_lancet()